import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useSystemStore = defineStore(
  'cp-system',
  () => {
    //侧边栏是否折叠
    const isCollapse = ref(false)

    //修改侧边菜单状态
    const updateIsCollapse = (status) => {
      isCollapse.value = status
    }

    //存储暗黑还是明亮模式
    const currentPattern = ref('bright')

    //改变模式
    const changePattern = (pattern) => {
      localStorage.setItem('themeColor', pattern)
    }
    return {
      isCollapse,
      updateIsCollapse,
      currentPattern,
      changePattern
    }
  },
  {
    //开启持久化
    persist: true
  }
)
